<template>
  <div class="watherModule">
    <div class="watherModule-org">
      <dl>
        <dd @click="changeOrg">
          <span>{{org[0].label}}</span>
          <i class="iconfont iconangle-down"></i>
        </dd>
        <dt>
          <span>{{time}}</span>
          <!-- <span>晴</span> -->
        </dt>
      </dl>
    </div>
    <div class="watherModule-weather">
      <img :src="weatherImage.sun" alt />
    </div>
    <Org
      ref="org"
      v-if="openOrg"
      v-model="org"
      @change="orgChange"
      :open="openOrg"
      title="选择组织"
      orgType="all"
      @confirm="confirmOrgDialog"
      @close="closeOrgDialog"
    ></Org>
  </div>
</template>
<script>
import Org from "@/select/org/Org.vue";
export default {
  name: "WeatherModule",
  data() {
    return {
      weatherImage: {
        sun: require("#/assets/img/weather/weather.png")
      },
      openOrg: false,
      org: [
        {
          label: "",
          value: "",
          disabled: false,
          checked: false,
          hasChecked: true,
          hasChildren: true
        }
      ],
      time:new Date().toLocaleDateString().replace(/\//g,'.')
    };
  },
  components: {
    Org
  },
  watch: {},
  computed: {},
  created() {
    this.org[0].label = this.$A.GS("orgInfo")["orgName"];
    this.org[0].value = this.$A.GS("orgInfo")["orgId"];
  },
  mounted() {},
  methods: {
    changeOrg() {
      this.openOrg = true;
    },
    orgChange(ev) {
      let orgInfo = {
        orgId: ev[0].value,
        orgName: ev[0].label,
        type: ev[0].type
      };
      this.$A.SS("orgInfo", orgInfo);
      this.changeNowOrg(ev[0])
    },
    //切换层级
    changeNowOrg(data){
      let obj = {
        "obj":{
          "orgId":data.value,
          "orgName":data.label,
          "orgType":data.type,
        }
      }
      this.$A.Go('post', '/safety/switchOrg', obj).then(success => {}, function (err) {})
    },
    confirmOrgDialog() {
      this.openOrg = false;
    },
    closeOrgDialog() {
      this.openOrg = false;
    }
  },
  destroyed() {}
};
</script>